#include <fcntl.h>
#include <sys/types.h>
#include <signal.h>
-
#include "utils.h"
void xprintf(const char *fmt, ...)
{
- static FILE *out = NULL;
va_list args;
- if (!out)
- out = stderr;
+
+ if (!stderr)
+ return; /* could trace()? */
va_start(args, fmt);
- vfprintf(out, fmt, args);
+ vfprintf(stderr, fmt, args);
va_end(args);
- fflush(out);
+ fflush(stderr);
}
void barf(const char *fmt, ...)
if (pidfile)
write_pidfile(pidfile);
- talloc_enable_leak_report_full();
+ /* Talloc leak reports go to stderr, which is closed if we fork. */
+ if (!dofork)
+ talloc_enable_leak_report_full();
/* Create sockets for them to listen to. */
sock = talloc(talloc_autofree_context(), int);
close(STDIN_FILENO);
close(STDOUT_FILENO);
close(STDERR_FILENO);
+
+ /* Get ourselves a nice xenstored crash if these are used. */
+ stdin = NULL;
+ stdout = NULL;
+ stderr = NULL;
}
signal(SIGHUP, trigger_reopen_log);
struct domain *d;
d = find_domain_by_domid(domid);
- if (d) {
- if ((d->nbentry += num) < 0) {
- eprintf("invalid domain entry number %d",
- d->nbentry);
- d->nbentry = 0;
- }
- }
+ if (d && ((d->nbentry += num) < 0))
+ d->nbentry = 0;
}
int domain_entry(struct connection *conn)
#include <fcntl.h>
#include <stdio.h>
#include <stdarg.h>
-
+#include <string.h>
#include "xs_lib.h"
#include "tdb.h"
#include "talloc.h"